// Generated from antlr/demo.g4 by ANTLR 4.9.0-SNAPSHOT


import { ATN } from "antlr4ts/atn/ATN";
import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
import { FailedPredicateException } from "antlr4ts/FailedPredicateException";
import { NotNull } from "antlr4ts/Decorators";
import { NoViableAltException } from "antlr4ts/NoViableAltException";
import { Override } from "antlr4ts/Decorators";
import { Parser } from "antlr4ts/Parser";
import { ParserRuleContext } from "antlr4ts/ParserRuleContext";
import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator";
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
import { RecognitionException } from "antlr4ts/RecognitionException";
import { RuleContext } from "antlr4ts/RuleContext";
//import { RuleVersion } from "antlr4ts/RuleVersion";
import { TerminalNode } from "antlr4ts/tree/TerminalNode";
import { Token } from "antlr4ts/Token";
import { TokenStream } from "antlr4ts/TokenStream";
import { Vocabulary } from "antlr4ts/Vocabulary";
import { VocabularyImpl } from "antlr4ts/VocabularyImpl";

import * as Utils from "antlr4ts/misc/Utils";

import { demoListener } from "./demoListener";
import { demoVisitor } from "./demoVisitor";


export class demoParser extends Parser {
	public static readonly T__0 = 1;
	public static readonly T__1 = 2;
	public static readonly T__2 = 3;
	public static readonly T__3 = 4;
	public static readonly T__4 = 5;
	public static readonly T__5 = 6;
	public static readonly T__6 = 7;
	public static readonly INT = 8;
	public static readonly DIGIT = 9;
	public static readonly ID = 10;
	public static readonly NameChar = 11;
	public static readonly STRING_ = 12;
	public static readonly BOOL_ = 13;
	public static readonly LETT = 14;
	public static readonly RIGHT = 15;
	public static readonly WS = 16;
	public static readonly RULE_file = 0;
	public static readonly RULE_section = 1;
	public static readonly RULE_section_header = 2;
	public static readonly RULE_attribute = 3;
	public static readonly RULE_instance = 4;
	public static readonly RULE_agrs = 5;
	public static readonly RULE_value = 6;
	// tslint:disable:no-trailing-whitespace
	public static readonly ruleNames: string[] = [
		"file", "section", "section_header", "attribute", "instance", "agrs", 
		"value",
	];

	private static readonly _LITERAL_NAMES: Array<string | undefined> = [
		undefined, "'='", "'('", "','", "')'", "'true'", "'false'", "'null'", 
		undefined, undefined, undefined, undefined, undefined, undefined, "'['", 
		"']'",
	];
	private static readonly _SYMBOLIC_NAMES: Array<string | undefined> = [
		undefined, undefined, undefined, undefined, undefined, undefined, undefined, 
		undefined, "INT", "DIGIT", "ID", "NameChar", "STRING_", "BOOL_", "LETT", 
		"RIGHT", "WS",
	];
	public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(demoParser._LITERAL_NAMES, demoParser._SYMBOLIC_NAMES, []);

	// @Override
	// @NotNull
	public get vocabulary(): Vocabulary {
		return demoParser.VOCABULARY;
	}
	// tslint:enable:no-trailing-whitespace

	// @Override
	public get grammarFileName(): string { return "demo.g4"; }

	// @Override
	public get ruleNames(): string[] { return demoParser.ruleNames; }

	// @Override
	public get serializedATN(): string { return demoParser._serializedATN; }

	protected createFailedPredicateException(predicate?: string, message?: string): FailedPredicateException {
		return new FailedPredicateException(this, predicate, message);
	}

	constructor(input: TokenStream) {
		super(input);
		this._interp = new ParserATNSimulator(demoParser._ATN, this);
	}
	// @RuleVersion(0)
	public file(): FileContext {
		let _localctx: FileContext = new FileContext(this._ctx, this.state);
		this.enterRule(_localctx, 0, demoParser.RULE_file);
		let _la: number;
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 15;
			this._errHandler.sync(this);
			_la = this._input.LA(1);
			do {
				{
				{
				this.state = 14;
				this.section();
				}
				}
				this.state = 17;
				this._errHandler.sync(this);
				_la = this._input.LA(1);
			} while (_la === demoParser.LETT);
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public section(): SectionContext {
		let _localctx: SectionContext = new SectionContext(this._ctx, this.state);
		this.enterRule(_localctx, 2, demoParser.RULE_section);
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 19;
			this.section_header();
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public section_header(): Section_headerContext {
		let _localctx: Section_headerContext = new Section_headerContext(this._ctx, this.state);
		this.enterRule(_localctx, 4, demoParser.RULE_section_header);
		let _la: number;
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 21;
			this.match(demoParser.LETT);
			this.state = 22;
			this.match(demoParser.ID);
			this.state = 24;
			this._errHandler.sync(this);
			_la = this._input.LA(1);
			do {
				{
				{
				this.state = 23;
				this.attribute();
				}
				}
				this.state = 26;
				this._errHandler.sync(this);
				_la = this._input.LA(1);
			} while (_la === demoParser.ID);
			this.state = 28;
			this.match(demoParser.RIGHT);
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public attribute(): AttributeContext {
		let _localctx: AttributeContext = new AttributeContext(this._ctx, this.state);
		this.enterRule(_localctx, 6, demoParser.RULE_attribute);
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 30;
			this.match(demoParser.ID);
			this.state = 31;
			this.match(demoParser.T__0);
			this.state = 32;
			this.value();
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public instance(): InstanceContext {
		let _localctx: InstanceContext = new InstanceContext(this._ctx, this.state);
		this.enterRule(_localctx, 8, demoParser.RULE_instance);
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 34;
			this.match(demoParser.ID);
			this.state = 35;
			this.agrs();
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public agrs(): AgrsContext {
		let _localctx: AgrsContext = new AgrsContext(this._ctx, this.state);
		this.enterRule(_localctx, 10, demoParser.RULE_agrs);
		let _la: number;
		try {
			this.enterOuterAlt(_localctx, 1);
			{
			this.state = 37;
			this.match(demoParser.T__1);
			this.state = 38;
			this.value();
			this.state = 43;
			this._errHandler.sync(this);
			_la = this._input.LA(1);
			while (_la === demoParser.T__2) {
				{
				{
				this.state = 39;
				this.match(demoParser.T__2);
				this.state = 40;
				this.value();
				}
				}
				this.state = 45;
				this._errHandler.sync(this);
				_la = this._input.LA(1);
			}
			this.state = 46;
			this.match(demoParser.T__3);
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}
	// @RuleVersion(0)
	public value(): ValueContext {
		let _localctx: ValueContext = new ValueContext(this._ctx, this.state);
		this.enterRule(_localctx, 12, demoParser.RULE_value);
		try {
			this.state = 54;
			this._errHandler.sync(this);
			switch (this._input.LA(1)) {
			case demoParser.ID:
				this.enterOuterAlt(_localctx, 1);
				{
				this.state = 48;
				this.instance();
				}
				break;
			case demoParser.INT:
				this.enterOuterAlt(_localctx, 2);
				{
				this.state = 49;
				this.match(demoParser.INT);
				}
				break;
			case demoParser.STRING_:
				this.enterOuterAlt(_localctx, 3);
				{
				this.state = 50;
				this.match(demoParser.STRING_);
				}
				break;
			case demoParser.T__4:
				this.enterOuterAlt(_localctx, 4);
				{
				this.state = 51;
				this.match(demoParser.T__4);
				}
				break;
			case demoParser.T__5:
				this.enterOuterAlt(_localctx, 5);
				{
				this.state = 52;
				this.match(demoParser.T__5);
				}
				break;
			case demoParser.T__6:
				this.enterOuterAlt(_localctx, 6);
				{
				this.state = 53;
				this.match(demoParser.T__6);
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (re) {
			if (re instanceof RecognitionException) {
				_localctx.exception = re;
				this._errHandler.reportError(this, re);
				this._errHandler.recover(this, re);
			} else {
				throw re;
			}
		}
		finally {
			this.exitRule();
		}
		return _localctx;
	}

	public static readonly _serializedATN: string =
		"\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03\x12;\x04\x02" +
		"\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06\x04\x07" +
		"\t\x07\x04\b\t\b\x03\x02\x06\x02\x12\n\x02\r\x02\x0E\x02\x13\x03\x03\x03" +
		"\x03\x03\x04\x03\x04\x03\x04\x06\x04\x1B\n\x04\r\x04\x0E\x04\x1C\x03\x04" +
		"\x03\x04\x03\x05\x03\x05\x03\x05\x03\x05\x03\x06\x03\x06\x03\x06\x03\x07" +
		"\x03\x07\x03\x07\x03\x07\x07\x07,\n\x07\f\x07\x0E\x07/\v\x07\x03\x07\x03" +
		"\x07\x03\b\x03\b\x03\b\x03\b\x03\b\x03\b\x05\b9\n\b\x03\b\x02\x02\x02" +
		"\t\x02\x02\x04\x02\x06\x02\b\x02\n\x02\f\x02\x0E\x02\x02\x02\x02;\x02" +
		"\x11\x03\x02\x02\x02\x04\x15\x03\x02\x02\x02\x06\x17\x03\x02\x02\x02\b" +
		" \x03\x02\x02\x02\n$\x03\x02\x02\x02\f\'\x03\x02\x02\x02\x0E8\x03\x02" +
		"\x02\x02\x10\x12\x05\x04\x03\x02\x11\x10\x03\x02\x02\x02\x12\x13\x03\x02" +
		"\x02\x02\x13\x11\x03\x02\x02\x02\x13\x14\x03\x02\x02\x02\x14\x03\x03\x02" +
		"\x02\x02\x15\x16\x05\x06\x04\x02\x16\x05\x03\x02\x02\x02\x17\x18\x07\x10" +
		"\x02\x02\x18\x1A\x07\f\x02\x02\x19\x1B\x05\b\x05\x02\x1A\x19\x03\x02\x02" +
		"\x02\x1B\x1C\x03\x02\x02\x02\x1C\x1A\x03\x02\x02\x02\x1C\x1D\x03\x02\x02" +
		"\x02\x1D\x1E\x03\x02\x02\x02\x1E\x1F\x07\x11\x02\x02\x1F\x07\x03\x02\x02" +
		"\x02 !\x07\f\x02\x02!\"\x07\x03\x02\x02\"#\x05\x0E\b\x02#\t\x03\x02\x02" +
		"\x02$%\x07\f\x02\x02%&\x05\f\x07\x02&\v\x03\x02\x02\x02\'(\x07\x04\x02" +
		"\x02(-\x05\x0E\b\x02)*\x07\x05\x02\x02*,\x05\x0E\b\x02+)\x03\x02\x02\x02" +
		",/\x03\x02\x02\x02-+\x03\x02\x02\x02-.\x03\x02\x02\x02.0\x03\x02\x02\x02" +
		"/-\x03\x02\x02\x0201\x07\x06\x02\x021\r\x03\x02\x02\x0229\x05\n\x06\x02" +
		"39\x07\n\x02\x0249\x07\x0E\x02\x0259\x07\x07\x02\x0269\x07\b\x02\x027" +
		"9\x07\t\x02\x0282\x03\x02\x02\x0283\x03\x02\x02\x0284\x03\x02\x02\x02" +
		"85\x03\x02\x02\x0286\x03\x02\x02\x0287\x03\x02\x02\x029\x0F\x03\x02\x02" +
		"\x02\x06\x13\x1C-8";
	public static __ATN: ATN;
	public static get _ATN(): ATN {
		if (!demoParser.__ATN) {
			demoParser.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(demoParser._serializedATN));
		}

		return demoParser.__ATN;
	}

}

export class FileContext extends ParserRuleContext {
	public section(): SectionContext[];
	public section(i: number): SectionContext;
	public section(i?: number): SectionContext | SectionContext[] {
		if (i === undefined) {
			return this.getRuleContexts(SectionContext);
		} else {
			return this.getRuleContext(i, SectionContext);
		}
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_file; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterFile) {
			listener.enterFile(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitFile) {
			listener.exitFile(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitFile) {
			return visitor.visitFile(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class SectionContext extends ParserRuleContext {
	public section_header(): Section_headerContext {
		return this.getRuleContext(0, Section_headerContext);
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_section; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterSection) {
			listener.enterSection(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitSection) {
			listener.exitSection(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitSection) {
			return visitor.visitSection(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class Section_headerContext extends ParserRuleContext {
	public LETT(): TerminalNode { return this.getToken(demoParser.LETT, 0); }
	public ID(): TerminalNode { return this.getToken(demoParser.ID, 0); }
	public RIGHT(): TerminalNode { return this.getToken(demoParser.RIGHT, 0); }
	public attribute(): AttributeContext[];
	public attribute(i: number): AttributeContext;
	public attribute(i?: number): AttributeContext | AttributeContext[] {
		if (i === undefined) {
			return this.getRuleContexts(AttributeContext);
		} else {
			return this.getRuleContext(i, AttributeContext);
		}
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_section_header; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterSection_header) {
			listener.enterSection_header(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitSection_header) {
			listener.exitSection_header(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitSection_header) {
			return visitor.visitSection_header(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class AttributeContext extends ParserRuleContext {
	public ID(): TerminalNode { return this.getToken(demoParser.ID, 0); }
	public value(): ValueContext {
		return this.getRuleContext(0, ValueContext);
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_attribute; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterAttribute) {
			listener.enterAttribute(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitAttribute) {
			listener.exitAttribute(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitAttribute) {
			return visitor.visitAttribute(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class InstanceContext extends ParserRuleContext {
	public ID(): TerminalNode { return this.getToken(demoParser.ID, 0); }
	public agrs(): AgrsContext {
		return this.getRuleContext(0, AgrsContext);
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_instance; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterInstance) {
			listener.enterInstance(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitInstance) {
			listener.exitInstance(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitInstance) {
			return visitor.visitInstance(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class AgrsContext extends ParserRuleContext {
	public value(): ValueContext[];
	public value(i: number): ValueContext;
	public value(i?: number): ValueContext | ValueContext[] {
		if (i === undefined) {
			return this.getRuleContexts(ValueContext);
		} else {
			return this.getRuleContext(i, ValueContext);
		}
	}
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_agrs; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterAgrs) {
			listener.enterAgrs(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitAgrs) {
			listener.exitAgrs(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitAgrs) {
			return visitor.visitAgrs(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


export class ValueContext extends ParserRuleContext {
	public instance(): InstanceContext | undefined {
		return this.tryGetRuleContext(0, InstanceContext);
	}
	public INT(): TerminalNode | undefined { return this.tryGetToken(demoParser.INT, 0); }
	public STRING_(): TerminalNode | undefined { return this.tryGetToken(demoParser.STRING_, 0); }
	constructor(parent: ParserRuleContext | undefined, invokingState: number) {
		super(parent, invokingState);
	}
	// @Override
	public get ruleIndex(): number { return demoParser.RULE_value; }
	// @Override
	public enterRule(listener: demoListener): void {
		if (listener.enterValue) {
			listener.enterValue(this);
		}
	}
	// @Override
	public exitRule(listener: demoListener): void {
		if (listener.exitValue) {
			listener.exitValue(this);
		}
	}
	// @Override
	public accept<Result>(visitor: demoVisitor<Result>): Result {
		if (visitor.visitValue) {
			return visitor.visitValue(this);
		} else {
			return visitor.visitChildren(this);
		}
	}
}


